Socket
Book a DemoInstallSign in
Socket

@tiptap/suggestion

Package Overview
Dependencies
Maintainers
5
Versions
312
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/suggestion

suggestion plugin for tiptap

2.26.1
Source
npmnpm
Version published
Weekly downloads
690K
-5.18%
Maintainers
5
Weekly downloads
 
Created

What is @tiptap/suggestion?

@tiptap/suggestion is a plugin for the Tiptap editor that provides a way to add suggestions to your editor. This can be used for implementing features like mentions, hashtags, or any other type of inline suggestions.

What are @tiptap/suggestion's main functionalities?

Basic Suggestion Setup

This code sets up a basic suggestion plugin that triggers on the '@' character. When a suggestion is selected, it inserts a mention node at the current position.

import { Suggestion } from '@tiptap/suggestion';

const suggestion = Suggestion({
  char: '@',
  startOfLine: false,
  command: ({ editor, range, props }) => {
    editor.chain().focus().insertContentAt(range, [
      {
        type: 'mention',
        attrs: props,
      },
      {
        type: 'text',
        text: ' ',
      },
    ]).run();
  },
});

Customizing Suggestion Menu

This code customizes the suggestion menu to trigger on the '#' character and filter items based on the query. It uses Vue and Tippy.js to render and manage the suggestion list.

import { Suggestion } from '@tiptap/suggestion';

const suggestion = Suggestion({
  char: '#',
  startOfLine: false,
  items: ({ query }) => {
    return [
      { title: 'JavaScript', id: 1 },
      { title: 'TypeScript', id: 2 },
      { title: 'React', id: 3 },
    ].filter(item => item.title.toLowerCase().includes(query.toLowerCase()));
  },
  render: () => {
    let component;
    let popup;

    return {
      onStart: props => {
        component = new Vue({
          render: h => h(SuggestionList, { props }),
        }).$mount();
        popup = tippy('body', {
          getReferenceClientRect: props.clientRect,
          appendTo: () => document.body,
          content: component.$el,
          showOnCreate: true,
        });
      },
      onUpdate: props => {
        component.$props = props;
        popup[0].setProps({
          getReferenceClientRect: props.clientRect,
        });
      },
      onExit: () => {
        popup[0].destroy();
        component.$destroy();
      },
    };
  },
});

Other packages similar to @tiptap/suggestion

Keywords

tiptap

FAQs

Package last updated on 11 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.